import { defineStore } from 'pinia'
import { getUserInfoAPI } from '@/api/userinfo.js'
export const useUserInfo = defineStore('userinfo', {
  state: () => {
    return {
      imageUrl: '',
      name: '',
      sex: '',
      department: '',
      identity: '',
      account: '',
      email: '',
    }
  },
  actions: {
    async userInfo(id) {
      const res = await getUserInfoAPI(id)
      this.imageUrl = res.data.data.image_url
      this.name = res.data.data.name
      this.sex = res.data.data.sex
      this.department = res.data.data.department
      this.identity = res.data.data.identity
      this.account = res.data.data.account
      this.email = res.data.data.email
    }
  },
  persist: true
}
)